package com.njitzx.fileupload.controller;

import com.njitzx.fileupload.pojo.Article;
import com.njitzx.fileupload.service.ArticleService;
import com.njitzx.fileupload.util.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/article")
public class ArticleController {

    @Autowired
    private ArticleService articleService;

    // 发布文章
    @PostMapping
    public AjaxResult publishArticle(@RequestBody Article article) {
        articleService.publishArticle(article);
        return AjaxResult.success();
    }

    //点赞文章
    @PostMapping("/like/{id}")
    public AjaxResult likeArticle(@PathVariable("id") Integer id) {
        articleService.likeArticle(id);
        return AjaxResult.success();
    }

    @GetMapping("/like/{id}")
    public AjaxResult getArticleLikeCount(@PathVariable("id") Integer id) {
        Integer count = articleService.getArticleLikeCount(id);
        return AjaxResult.success(count);
    }


    //查看文章内容


}
